﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataModel;
using SchoolBusiness;

namespace SchoolAdministration
{
    public partial class AddSubject : System.Web.UI.Page
    {
        private readonly BLRoutine _blroutine = new BLRoutine(); 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<Grade> grade = _blroutine.GetGrade();
                ClassDropdown.DataSource = grade;
                ClassDropdown.DataTextField = "ClassName";
                ClassDropdown.DataValueField = "ClassId";
                ClassDropdown.DataBind();
                TxtSubject.Text = "";
              
                
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            Subject _subject = new Subject()
            {
                
                SubjectName = TxtSubject.Text,
                SubjectCode = TxtSubjectCode.Text,
                ClassGrade = new Grade() 
                { 
                    ClassId=Convert.ToInt32(ClassDropdown.Text)
                },


            };
            int result = _blroutine.AddSubject(_subject);
            if (result > 1)
            {
                MsgDisplaylbl.Text = "Successfully Added the  Subject";
            }
        }
    }
}